﻿namespace NetFx.SMIL.References
{
  using System;
  using System.Text;
  using System.Collections;
  using System.Collections.Generic;

  using System.Reflection;
  using System.Reflection.Emit;
  using System.Runtime.InteropServices;

  using System.Diagnostics;
  using System.Diagnostics.CodeAnalysis;
  using System.Diagnostics.SymbolStore;
  using System.Security;
  using System.Security.Permissions;

  using NetFx.MSIL;

  /// <summary>
  /// 对枚举的引用。
  /// </summary>
  public class EnumRef : TypeRef
  {
    #region Statics
    public new static EnumRef it()
    {
      return new EnumRef();
    }
    public new static EnumRef of(Type enumType)
    {
      return new EnumRef(enumType);
    }
    public new static EnumRef of(string identifier)
    {
      return new EnumRef(identifier);
    }
    #endregion
    #region Properties
    /// <summary>
    /// 获取引用类型（为枚举）。
    /// </summary>
    public override DefType ReflectionType
    {
      get { return DefType.Event; }
    }

    #endregion
    #region Constructors
    public EnumRef() : base() { }
    public EnumRef(string identifier) : base(identifier) { }
    public EnumRef(Type enumType)
      : base()
    {
      if (enumType != null && enumType.IsEnum)
      {
        this.OnBinding(enumType);
      }
    }
    #endregion
    #region Methods
    protected override ReflectRef OnBinding(object source)
    {
      Type enumType = source as Type;
      return base.OnBinding(enumType != null && !enumType.IsEnum ? enumType:null);
    }
    #endregion
  }
}
